package beanLife;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author quan
 * @Description 用代码演示Bean的生命周期
 * @Date 2023/7/18 21:10
 */
public class Main {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //通过类名拿到对象
        BeanLifeComponent component = context.getBean((BeanLifeComponent.class));
        //执行sayHello方法
//        component.sayHello();
        //销毁方法
        component.preDestroy();
    }
}
